package com.hbnu.array;

import java.util.Random;
import java.util.Scanner;

public class DemoArray7 {
    //程序生成数字，猜数字
    public static void main(String[] args) {
        Random random = new Random();
        int target = random.nextInt(100)+1;
        int num_in;
        Scanner reader = new Scanner(System.in);

        do {
            try{
                num_in = reader.nextInt();
            }
            catch (Exception e){
                System.out.println("error");
                num_in = -1;//达成循环条件
                continue;
            }
            if (num_in>target){
                System.out.println("大了");
            } else if (num_in<target) {
                System.out.println("小了");
            }else {
                System.out.println("猜对了");
            }
        }while(num_in!=target);
    }
}
